/**
 * Api定义抽象类
 */
import http from '@ohos.net.http'
export default abstract class api{
  url:string
  query:Map<string,string>
  body:object
  method:http.RequestMethod=http.RequestMethod.GET
  protected constructor() {

  }
  getQueryStr(){
    if(this.query === undefined || this.query === null || this.query.size === 0){
      return ''
    }
    let qs = ''
    this.query.forEach((value,key)=>{
      qs += `${key}=${value}&`
    })
    return qs.slice(0,-1)
  }
  getBodyStr(){
    if(this.body === undefined || this.body === null)
      return ''
    return JSON.stringify(this.body)
  }
}